BAG
Section: SOS CLASS LIBRARY (3S)
Updated: 28/10/1991
Index
Return to Main Contents
man2html: unable to open or read file
/usr/lib/ms/ms.acc
NAME
Bag<Entity> - predefined class Bag
SYNOPSIS
#include "<SOS>/include/agg_sos.h"
class Bag<Entity> (sos_Bool list_cursor = TRUE,
sos_Bool based_on_equal = FALSE)
: Collection<Entity> (based_on_equal)
{
public:
sos_Int insert (Entity);
sos_Int remove (Entity);
void eliminate (Entity);
sos_Int occurrences (Entity);
void max_union (Bag<Entity>);
void operator+= (Bag<Entity>);
void operator-= (Bag<Entity>);
void operator*= (Bag<Entity>);
sos_Bool operator< (Bag<Entity>);
sos_Bool operator<= (Bag<Entity>);
sos_Bool operator> (Bag<Entity>);
sos_Bool operator>= (Bag<Entity>);
// ** sos_Cursor operations **
sos_Int entity_occurs (sos_Cursor);
sos_Bool to_diff_succ (sos_Cursor, sos_Int = 1);
sos_Bool to_diff_pred (sos_Cursor, sos_Int = 1);
}
DESCRIPTION
The class
Bag<Entity> provides
means for manipulating generic multisets. The type of the elements of a
Bag is stated when the Bag type is instantiated (Methods that overwrite
inherited methods are only described in the superclass, where they are
inherited from - provided that they are semantically equivalent).
In the following self will denote the state of
the Bag before the respective operation is applied, while
self' denotes the state of the Bag after the
execution of the method.
- Bag::create (ct, list_cursor, based_on_equal)
-
The create parameter based_on_equal
determines if tests for membership in the Bag should be based on the
equality or identity of the respective entities, as in superclass
Collection. The additional parameter
list_cursor decides, whether the Bag may
dynamically be modified while a cursor iterates over the structure. If
list_cursor == FALSE, and modifying operations
are performed on a Bag during a scan with a sos_Cursor, the behavior of
sos_Cursor operations after the modification is undefined. On the other
hand, a bag that is created with list_cursor == TRUE will require a bit more of persistent memory.
- insert (e)
-
inserts entity e (perhaps again). The new
number of occurences of e is
returned.
POSTCONDITION: self'.occurences (e) == self.occurences (e) + 1
- remove (e)
-
removes one occurence of entity e. The
former number of occurences of e is
returned.
POSTCONDITION: self'.occurences (e) == MAX (self.occurences (e) - 1, 0)
- eliminate (e)
-
removes all occurences of the given entity
e from the Bag.
- occurences (e)
-
returns the number of occurences of the given entity
e in the Bag.
- max_union (b)
-
performs a union with Bag
b.
POSTCONDITION: self'.occurences (e) == MAX (self.occurences (e), b.occurences (e))
- operator+= (b)
-
adds Bag b to this Bag.
POSTCONDITION: self'.occurences (e) == self.occurences (e) + b.occurences (e)
- operator-= (b)
-
subtracts Bag b from
self.
POSTCONDITION: self'.occurences (e) == MAX (self.occurences (e) - b.occurences (e), 0)
- operator*= (b)
-
intersects Bag b with
self.
POSTCONDITION: self'.occurences (e) == MIN (self.occurences (e) - b.occurences (e), 0)
- operator< (b)
-
returns TRUE if
self is a subset of Bag
b, FALSE otherwise,
i.e:
TRUE if self.operator<=(b) AND NOT self.equal (b)
- operator<= (b)
-
returns TRUE if
self is a subset of Bag
b or if self is equal
to Bag b, FALSE
otherwise, i.e:
TRUE if self.occurences (e) <= b.occurences (e)
- operator> (b)
-
returns TRUE if
self is a superset of Bag
b, FALSE otherwise,
i.e:
TRUE if self.operator>= (b) AND NOT self.equal (b)
- operator>= (b)
-
returns TRUE if
self is a superset of Bag
b or if self is equal
to Bag b, FALSE
otherwise, i.e:
TRUE if self.occurences (e) >= b.occurences (e)
- equal (b)
-
returns TRUE if
self.occurences (e) == b.occurences (e)
The following methods require an open
sos_Cursor(3) as input parameter:
- entity_occurs (c)
-
returns self.occurences (self.get (c)).
PRECONDITION: is_valid (c)
- to_diff_succ (c, i)
-
to_diff_succ (c, i) marks all occurences
of self.get (c) as already seen and positions
the specified sos_Cursor to the next different element of the Bag. If
i is specified, all occurences of the next
different i elements are jumped, as if the
function was applied i-times. The function
returns TRUE if the sos_Cursor is still valid
after the operation, i.e. if there is an Entity at this sos_Cursor
position. It returns FALSE
otherwise.
PRECONDITION: is_valid (c) AND (i >= 0)
- to_diff_pred (c, i)
-
to_diff_pred (c, i) marks all occurences
of self.get (c) as already seen and positions
the specified sos_Cursor to the preceding different element of the Bag.
If i is specified, all occurences of the next
different i elements are jumped, as if the
function was applied i-times. The function
returns TRUE if the sos_Cursor is still valid
after the operation, i.e. if there is an Entity at this sos_Cursor
position. It returns FALSE
otherwise.
PRECONDITION: is_valid (c) AND (i >= 0)
FILES
- <SOS>/src/agg/agg.sos
-
SOS schema file
- <SOS>/src/agg/agg_sos.h
-
complete schema interface
- <SOS>/src/agg/agg_use.h
-
restricted schema interface
- <SOS>/src/agg/agg_ext.h
-
definition of iterators (automatically included by agg_use.h)
- <SOS>/src/agg/Bag.c
-
Bag implementation file
- <SOS>/lib/sos.a
-
SOS library
SEE_ALSO
sos_Object(3), sos_Aggregate(3), Collection(3), sos_Cursor(3)
AUTHOR
Bernhard Schiefer, Dietmar Theobald
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- FILES
-
- SEE_ALSO
-
- AUTHOR
-
This document was created by
man2html,
using the manual pages.
Time: 00:37:57 GMT, March 30, 2022